[Android] Returning to a ListView with a text filter
Posted
by sosiouxme
on Stack Overflow
See other posts from Stack Overflow
or by sosiouxme
Published on 2010-02-06T20:38:08Z
Indexed on
2010/05/05
22:28 UTC
Read the original article
Hit count: 146
I enabled text filtering on my ListView in the expected way; adding android:textFilterEnabled=”true”
in resource definition and (as I'm using a SimpleCursorAdapter) setting a FilterQueryProvider that provides a filtered cursor like so:
public Cursor runQuery(CharSequence constraint) {
Cursor cur = mDba.fetchTrackers(mCurrentGroupId, constraint.toString());
startManagingCursor(cur);
return cur;
}
My question is this: once the user selects a list item, goes off to another activity, and returns to this one, how can I control the state of the filter previously applied?
What I'm seeing right now is that when I return to the activity, the cursor being used is the unfiltered one set on the filter at creation, but the filter text they typed is still shown (and typing keys causes the filter to be applied).
What I'd like to do is either clear the filter, or keep the filtered cursor that the activity was left with.
© Stack Overflow or respective owner